<?php

/**
 * bay3Mailer
 *
 * @package    bay3
 * @subpackage mailer
 * @author     Redouane
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class sellerMailer extends bay3Mailer
{
    
    /**
     * 
     */
    static public function initMailer(){
    	$contextInstance = sfContext::getInstance();
    	$contextInstance->getConfiguration()->loadHelpers('Partial');
    }
    
    /**
     * Envoi de mot de passe oublié au vendeur
     * @author red
     * @since 10/11
     * @param sfEvent $event
     */
    static public function passwordForget(sfEvent $event){
        $password = $event['password'];
        $to = $event['email'];
        $firstname = $event['firstname'];
        $subject = "Votre mot de passe";
        $from = 'no-replay@bay3wachira.com';
        $body ="Bonjour $firstname,<br/> Vous venez de demander l'envoie de votre mot de passe afin que vous puissiez vous connecter sur votre compte,<br/>votre mot de passe est: $password.";
        $body .= "A bientôt sur <a href='http://www.bay3wachira.com'>www.bay3wachira.com</a>";
        //self::sendEmail($to,$subject,$body,$from);
        self::sendMail($to,$subject,$body,$from,$firstname);
    }
    
    /**
     * bayerContact
     */
    static public function bayerContact(sfEvent $event){
        $to = $event['to'];
        $adsTitle = $event['adsTitle'];
        $body = $event['body'];
        
        $subject = "Un client est intéréssé par votre annonce $adsTitle";
        $from = 'no-replay@bay3wachira.com';
        
        self::sendMail($to,$subject,$body,$from);
    }
    
    /**
     * Contact-Us
     */
    static public function contactUs(sfEvent $event){
        $from = $event['from'];
		$to = "webmaster@bay3wachira.com";
        $subject = "[Bay3wachira CONTACT-US]";
        $body = "Un message de la rubrique contact-us :";
        $body .= "de la part de [" . $event['name'] . " - " . $event['url'] . "]";
        $body .= "<br/>Message : " . $event['body'];
        
        self::sendMail($to,$subject,$body,$from);
    }
    
    /**
     * signaler un abus
     */
    
    static public function signalabus(sfEvent $event){
        $from = $event['from'];
        $to = "webmaster@bay3wachira.com";
        $subject = "[SIGNALER ABUS]";
        $body = "Un message de contenu abusif :";
        $body .= "http://www.bay3wachira.com/" . $event['url'];
        $body .= "<br/>Message : " . $event['message'];
        
        self::sendMail($to,$subject,$body,$from);
    }
    
    /**
     * envoyer à un ami
     */
    static public function sendToFriend(sfEvent $event){
        $from = $event['from'];
        $to = $event['to'];
        $subject = "UN BON PLAN sur Bay3wachira.com";
        $body = $event['message'];
        $body .= "http://www.bay3wachira.com/" . $event['url'];
        $body .= "<br/>Profites bien ...<br/> A+.";
        
        self::sendMail($to,$subject,$body,$from);
    }
    
    /**
     * BACK : informer le webmaser de la nouvelle ads
     */
    static public function adminNewAds(sfEvent $event){
        $from = $event['from'];
        $to = 'webmaster@bay3wachira.com';
        $subject = "[NEW ADS]";
        $body = 'Nouvelle annonce à valider :' . $event['message'];
        
        self::sendMail($to,$subject,$body,$from);
    }

    /**
    *  envoi un mail au annonceur pour lui informer l'activation de son annonce
    */
	static public function adminSendActiveAdsToSeller(sfEvent $event){
        $ads = $event['ads'];
        $from = 'webmaster@bay3wachira.com';
        $subject = '[Bay3wachira] Activation de votre annonce';
        $body = "Bonjour,<br/>
On a le plaisir de vous informer que votre annonce est désormais visible sur  notre site <a href='http://www.bay3wachira.com' target='blank'>www.bay3wachira.com</a>
consultez les dernières annonces sur <a href='http://bay3wachira.com/dernieres-annonces-gratuites' target='blank'>http://www.bay3wachira.com/dernieres-annonces-gratuites</a>
<br />Bonne chance";
        $to = $ads->Seller->email. ',webmaster@bay3wachira.com';
        self::sendMail($to,$subject,$body,$from);
    }
}
